import React, { useState } from "react";
import {reqRegister} from '../../request/api'

const Register=(props)=>{
  const [user,setUser]=useState({phone:'',password:'',nickname:''})

  //注册
  const register=()=>{
    reqRegister(user).then((res)=>{
      if (res.data.code ===200) {
        props.history.push("/login");
      }
    })
  }
  return (
    <div>
      
            <div>
             手机号：
              <input type="text" value={user.phone} onChange={(e)=>setUser({...user,phone:e.target.value})} />
            </div>
            <div>
              昵称：
              <input type="text" value={user.nickname}  onChange={(e)=>setUser({...user,nickname:e.target.value})} />
            </div>
            <div>
              密码: <input type="text" value={user.password}  onChange={(e)=>setUser({...user,password:e.target.value})} />
            </div>
            <button onClick={()=>register()}>注册</button>
    </div>
  )
}
// class Register extends PureComponent {
//   render() {
//     let {
//         user: { phone, password, nickname },
//         register:{
//           changeUser,
//           reqRegister
//         },
//         history
//       } = this.props;
//     //   console.log(this.props)
//     return (
//        
//     );
//   }
// }

export default Register;
